/**
 * @Description:
 * @Author bianpengfei
 * @create 2022/1/4 22:33
 */
import { Vite } from '@bianpengfei/utils'
import errorRoutes from './modules/errors'
const { requireAllModule } = Vite

const routeModules = requireAllModule({
  requireContext: import.meta.globEager('./modules/**/*.js'),
  exclude: ['./modules/errors.js', './modules/index.js']
})
  .reduce((pre, cur) => {
    console.log('cur', cur)
    if (cur?.default) pre.push(cur.default)
    return pre
  }, [])
  .flat(Infinity)

console.log(routeModules)

export default [
  {
    path: '/',
    component: () => import('+libs/layout/default/'),
    children: [].concat(routeModules).concat(errorRoutes)
  }
]
